home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Communications / pcomm / Source / d_manual.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-12  |  1.9 KB  |  89 lines

  1. /*
  2.  * The manual dial option of the dialing directory.  A non-zero return code
  3.  * means we're ready to dial.  Dialing directory entry 0 is reserved
  4.  * for the manual dial option.  No sanity checking is done on the input.
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <curses.h>
  9. #include "config.h"
  10. #include "dial_dir.h"
  11. #include "misc.h"
  12.  
  13. int
  14. manual()
  15. {
  16.     extern int xmc;
  17.     extern char *null_ptr;
  18.     WINDOW *m_win, *newwin();
  19.     char *number, *str_rep(), *get_str(), ld_code, *strchr();
  20.     void free_ptr();
  21.     static void fix_xmc();
  22.  
  23.     m_win = newwin(5, 50, 0, 20);
  24.  
  25.     box(m_win, VERT, HORZ);
  26.     mvwaddstr(m_win, 2, 3, "Phone Number: ");
  27.     wrefresh(m_win);
  28.                     /* get a phone number */
  29.     if ((number = get_str(m_win, 30, "", "\n")) == NULL) {
  30.         werase(m_win);
  31.         wrefresh(m_win);
  32.         delwin(m_win);
  33.         if (xmc > 0)
  34.             fix_xmc();
  35.         return(0);
  36.     }
  37.                     /* is first char an LD code? */
  38.     ld_code = '\0';
  39.     if (strchr("+-@#", *number)) {
  40.         ld_code = *number;
  41.         number++;
  42.     }
  43.                     /* put it in the queue */
  44.     dir->q_ld[0] = ld_code;
  45.     dir->q_num[0] = 0;
  46.                     /* end of queue marker */
  47.     dir->q_num[1] = -1;
  48.     dir->d_cur = 0;
  49.                     /* build the entry zero */
  50.     dir->name[0] = str_rep(dir->name[0], number);
  51.                     /* if space, change to null_ptr */
  52.     if (!strcmp(number, " ")) {
  53.         free_ptr(dir->number[0]);
  54.         dir->number[0] = null_ptr;
  55.     }
  56.     else
  57.         dir->number[0] = str_rep(dir->number[0], number);
  58.                     /* it overlaps dm_win, so erase it */
  59.     werase(m_win);
  60.     wrefresh(m_win);
  61.     delwin(m_win);
  62.     if (xmc > 0)
  63.         fix_xmc();
  64.     return(1);
  65. }
  66.  
  67. /*
  68.  * Clear the end of the physical screen where the magic cookie got shifted
  69.  * Geez, I hate magic cookie terminals...  Wyse, are you listening?
  70.  */
  71.  
  72. static void
  73. fix_xmc()
  74. {
  75.     WINDOW *cl_win, *newwin();
  76.  
  77.     /*
  78.      * Since the cookie got shifted off the window, we have to
  79.      * create a new window to cover where the cookie ended up.
  80.      */
  81.     cl_win = newwin(1, 2, 4, 78);
  82.                     /* have to touch, otherwise nothing! */
  83.     touchwin(cl_win);
  84.     wrefresh(cl_win);
  85.     delwin(cl_win);
  86.  
  87.     return;
  88. }
  89.